import * as constants from "./constants";
import axios from "axios";

// import { fromJS } from "immutable";
export const changeHomeInfo = (data) => ({
  type: constants.CHANGE_HOME_DATA,
  data: data,
});

export const getHomeInfo = () => {
  return (dispatch) => {
    axios.get("/api/home.json").then((res) => {
      console.log(res.data.data);
      dispatch(changeHomeInfo(res.data.data));
    });
  };
};
export const addHomeList = (data, page) => ({
  type: constants.ADD_ARTICLE_LIST,
  data,
  page,
});
export const getMoreList = (page) => {
  return (dispatch) => {
    axios.get("/api/homeList.json?=" + page).then((res) => {
      console.log(res.data.data);
      const result=res.data.data//array

      dispatch(addHomeList(result, page+1));
    });
  };
};

export const toggleTopShow=(flag)=>({
  type:constants.TOGGLE_SCROLL_TOP,
  flag

})
